import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:x_project/web/web_controller.dart';
import 'package:x_project/web/x_web_view.dart';
import 'package:x_project/components/x_app_bar.dart';

/// Created by XieXin on 2020/3/20.
/// 通用webView
/// Get.toNamed(CommonRouter.webViewPage, arguments: {"title":"title","url":"url"});
/// Get.toNamed("/webViewPage?url=url&title=title");
class WebViewPage extends StatefulWidget {
  final controller = Get.find<WebController>();
  final dynamic args = Get.arguments;

  WebViewPage({Key? key}) : super(key: key);

  @override
  WebViewPageState createState() => WebViewPageState();
}

class WebViewPageState extends State<WebViewPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: XAppBar(title: widget.args["title"] ?? "Not Title"),
      body: XWebView(
        widget.args["url"] ?? "Not Url",
        key: Key(widget.args["title"] ?? "Not Title"),
      ),
    );
  }
}
